package com.shop2cn.iapi.subscription.testcase;

import org.junit.After;

import com.shop2cn.iapi.subscription.parameter.*;
import com.shop2cn.iapi.subscription.service.*;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*商家申请试用Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ApplyTryout{
	private static ApplyTryoutBean applytryoutBean;
	private static ApplyTryoutCall applytryoutCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商家申请试用Test");
	}

	@Before
	public void caseUp() {
		applytryoutBean=new ApplyTryoutBean();
		applytryoutCall=new ApplyTryoutCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(applytryoutCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ApplyTryout_001() {
		Logger.start(true,"未试用过商家申请直播试用一个月，成功");
		try {
			Integer mchId = GodmchManageCallService.CreateAllMsgSellerMch().getMchId();
			
			applytryoutBean.setMchId(mchId);
			applytryoutBean.setFuncType(0);
			applytryoutBean.setFuncPackageId(1);
			applytryoutCall.setData(applytryoutBean);
			applytryoutCall.callService();			
			Logger.verifyEquals("200", applytryoutCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ApplyTryout_002() {
		Logger.start(true,"商家【多次】申请直播试用一个月，失败");
		try {
			Integer mchId = GodmchManageCallService.CreateAllMsgSellerMch().getMchId();
			
			applytryoutBean.setMchId(mchId);
			applytryoutBean.setFuncType(0);
			applytryoutBean.setFuncPackageId(1);
			applytryoutCall.setData(applytryoutBean);
			applytryoutCall.callService();			
			Logger.verifyEquals("200", applytryoutCall.getString("code"), "验证code");
			applytryoutCall.callService();			
			Logger.verifyEquals("400", applytryoutCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	 
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ApplyTryout_003() {
		Logger.start(true,"商户id无效，失败");
		try {
			Integer mchId = GodmchManageCallService.CreateAllMsgSellerMch().getMchId();
			
			applytryoutBean.setMchId(11223);
			applytryoutBean.setFuncType(0);
			applytryoutBean.setFuncPackageId(1);
			applytryoutCall.setData(applytryoutBean);
			applytryoutCall.callService();			
			Logger.verifyEquals("400", applytryoutCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
}